package leecode

func sumOfTheDigitsOfHarshadNumber(x int) int {
	//求数字各个位置上的和
	sum := addSum(x)
	if x%sum == 0 {
		return sum
	}
	return -1
}

func addSum(num int) int {
	var sum int
	for num > 0 {
		temp := num % 10
		sum = sum + temp
		num = num / 10
	}
	return sum
}
